from celery import bootsteps
from kombu import Consumer, Exchange


class BaseCustomReplyConsumerStep(bootsteps.ConsumerStep):
    """消费者基类通过集成方式描写消费者"""

    exchange = Exchange(name='exchange_name', type='topic', durable=False)

    @property
    def queue(self):
        raise NotImplementedError

    def get_consumers(self, channel):
        return [Consumer(channel=channel, queues=[self.queue], callbacks=[self.callback], accept=['json'])]

    def callback(self, body, customer):
        raise NotImplementedError
